package com.alex.j2se.reference;

import java.lang.ref.PhantomReference;
import java.lang.ref.ReferenceQueue;

/**
 * Created by gaojun on 2017/11/15.
 */
public class PhantomRef {
    public static void main(String[] args) {
        ReferenceQueue refQueue = new ReferenceQueue();
        PhantomReference<Integer> phantomReference  = new PhantomReference(1, refQueue);
        Integer i = phantomReference.get();
        System.out.println(i);
        System.out.println(phantomReference.isEnqueued());
        phantomReference.enqueue();
        System.out.println(phantomReference.isEnqueued());
    }
}
